$(window).ready(function() {
	$('#box #nav li').filter(':not(.aniBorder)').hover(function(){
		$(this).stop().animate({borderWidth:3},100);
	},function(){
		$(this).stop().animate({borderWidth:0},100);
	});
	
	$(".inframe").fancybox({
		'width'				: '75%',
		'height'			: '75%',
		'autoScale'			: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'type'				: 'iframe',
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.9
	});
	
	$(".fancybox").fancybox({
		openEffect	: 'none',
		closeEffect	: 'none',
        'overlayColor'		: '#000',
        'overlayOpacity'	: 0.9			
	});
	
	if($("#condExp").val() == ""){
		$("#cond").hide();
		$('#typeConstraint option[value=XDF]').attr('selected', 'selected');
	} else {
		$("#cond").show();
		$('#typeConstraint option[value=XDFC]').attr('selected', 'selected');		
	}
	$("#typeConstraint").change(function() {
		  if($(this).val() == "XDF") {
			  $("#cond").hide();
			  $("#condExp").val("");
		  } else
			  $("#cond").fadeIn();
	});	

	$("#opt").change(function() {
		  if($(this).val() == "upload")
			$("#fileChoose").fadeIn();
		  else
			$("#fileChoose").fadeOut();
	});			
});

function validateForm(){
	var nameConstraint = document.forms["form"]["nameConstraint"].value;
	
	if (nameConstraint == null || nameConstraint == ""){
  		alert("Insert name constraint!");
  		return false;
	}
	
	var contex = document.forms["form"]["contex"].value;
	if (contex == null || contex == ""){
  		alert("Insert contex!");
  		return false;
	}
	
	var leftPath = document.forms["form"]["leftPath"].value;
	if (leftPath == null || leftPath == ""){
  		alert("Insert left path!");
  		return false;
	}
	
	var leftValue = document.forms["form"]["leftValue"].value;
	if (leftValue == null || leftValue == ""){
  		alert("Insert left value equalty!");
  		return false;
	}	
	
	var rightPath = document.forms["form"]["rightPath"].value;
	if (rightPath == null || rightPath == ""){
  		alert("Insert right path!");
  		return false;
	}
	
	var condition = document.forms["form"]["condition"].value;
	var type = document.forms["form"]["type"].value;
	if ( (condition == null && type == "XDFC") || (condition == ""  && type == "XDFC") ){
  		alert("Insert condition!");
  		return false;
	}			
}	

function validateUpload(){
	var option = document.forms["formUpload"]["option"].value;
	var file = document.forms["formUpload"]["file"].value;
	
	if ( (file == null && option == "upload") || (file == ""  && option == "upload") ){
  		alert("Insert file XML!");
  		return false;
	}
}